package cn.stylefeng.guns.modular.flowable.controller;

import cn.stylefeng.guns.core.common.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.flowable.entity.ActDeModel;
import cn.stylefeng.guns.modular.flowable.model.params.ActDeModelParam;
import cn.stylefeng.guns.modular.flowable.service.ActDeModelService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 工作流模板控制器
 *
 * @author gblfy
 * @Date 2019-12-16 17:22:39
 */
@Controller
@RequestMapping("/actDeModel")
public class ActDeModelController extends BaseController {

    private String PREFIX = "/modular/flowable/actDeModel";

    @Autowired
    private ActDeModelService actDeModelService;

    /**
     * 跳转到主页面
     *
     * @author gblfy
     * @Date 2019-12-16
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/actDeModel.html";
    }

    /**
     * 新增页面
     *
     * @author gblfy
     * @Date 2019-12-16
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/actDeModel_add.html";
    }

    /**
     * 编辑页面
     *
     * @author gblfy
     * @Date 2019-12-16
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/actDeModel_edit.html";
    }

    /**
     * 新增接口
     *
     * @author gblfy
     * @Date 2019-12-16
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ActDeModelParam actDeModelParam) {
        this.actDeModelService.add(actDeModelParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author gblfy
     * @Date 2019-12-16
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ActDeModelParam actDeModelParam) {
        this.actDeModelService.update(actDeModelParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author gblfy
     * @Date 2019-12-16
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ActDeModelParam actDeModelParam) {
        this.actDeModelService.delete(actDeModelParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author gblfy
     * @Date 2019-12-16
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ActDeModelParam actDeModelParam) {
        ActDeModel detail = this.actDeModelService.getById(actDeModelParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author gblfy
     * @Date 2019-12-16
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ActDeModelParam actDeModelParam) {
        return this.actDeModelService.findPageBySpec(actDeModelParam);
    }

}


